<!DOCTYPE html>
<html>
<body>
<script>
/* This script will be executed in a subframe. Do not use double slash comments
   or double quotes in this script tag, they break the test because of innerText
   call below. */
function runTest()
{
    eventSender.beginDragWithFiles(['resources/UTF8.txt']);
    eventSender.mouseMoveTo(20, 20);
    eventSender.mouseUp();
}

function onInputFileChange()
{
    var file = document.getElementById('file').files[0];
    var reader = new FileReader();
    reader.readAsText(file);
    console.log('Started reading...');
    top.postMessage('navigateToSuccess', '*');
}
</script>

<script>
if (window.eventSender) {
    testRunner.dumpAsText();
    testRunner.waitUntilDone();
}
document.write(
    '<script>' +
    'window.onmessage = function(evt){' +
    '  if (evt.data == "navigateToSuccess") {' +
    '    window.location = "resources/notify-no-crash.html";' +
    '  }' +
    '}' +
    '</scr' + 'ipt>' +
    '<iframe src="data:text/html,<input type=file id=file onchange=\'onInputFileChange()\'><script>' +
    document.getElementsByTagName("script")[0].innerText + 'runTest()</scr' + 'ipt>" style="left:0px;top:0px"></iframe>');
</script>

<p>Test that using FileReader from a document with unique origin doesn't cause a crash.</p>
<p>If testing manually, please drop a file on an input above.</p>
</body>
</html>
